<template>
  <el-dialog v-model="visible" title="导出配置" width="500">
    <el-form :model="form" ref="formRef" labelWidth="100px">
      <el-form-item
        label="导出数据"
        prop="type"
        :rules="[
          {
            required: true,
            message: '请选择导出数据',
            trigger: 'blur',
          },
        ]"
      >
        <el-radio-group v-model="form.type">
          <el-radio value="1" name="type"> 当前页 </el-radio>
          <el-radio value="2" name="type"> 全部页 </el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label="导出方式"
        prop="type"
        :rules="[
          {
            required: true,
            message: '请选择导出方式',
            trigger: 'blur',
          },
        ]"
      >
        <el-radio-group v-model="form.type">
          <el-radio value="1" name="type"> EXCEL </el-radio>
          <el-radio value="2" name="type"> PDF </el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitForm"> 确定 </el-button>
        <el-button @click="onCancel">取消</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup>
import { ref } from "vue";

const props = defineProps({
  typeName: { type: String, default: "新增" },
});
const visible = ref(false);
const formRef = ref();
const form = ref({
  type: [],
});

const submitForm = () => {
  formRef.value.validate((valid) => {
    if (valid) {
      console.log("submit!");
    } else {
      console.log("error submit!");
    }
  });
};

const onCancel = () => {
  formRef.value.clearValidate();
  visible.value = false;
};
const openDialog = (row) => {
  visible.value = true;
  // form.value = row || { type: [] };
};

defineExpose({
  openDialog,
});
</script>
